package com.jie.study

import android.content.Context
import android.content.Intent
import com.alibaba.android.arouter.facade.Postcard
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.facade.service.DegradeService
import com.blankj.utilcode.util.LogUtils

/**
 * 显示ARouter全局降级策略
 * 当ARouter找不到对应页面时，进入该回调进行处理
 */
@Route(path = DegradeServiceImpl.PATH)
class DegradeServiceImpl : DegradeService {
    override fun init(context: Context?) {
    }

    override fun onLost(context: Context?, postcard: Postcard?) {
        if (context != null){
            LogUtils.i("未找到对应页面：${postcard.toString()}")
            context.startActivity(
                Intent(context, NotFoundActivity::class.java)
            )
        }
    }

    companion object{
        const val PATH = "/service/NotFoundPage"
    }
}